#include "MarsPrecompile.h"

#include "MarsMeshMgr.h"
#include "MarsPipelineMgr.h"
#include "MarsMeshImporter.h"

using namespace Graphics;

MeshMgr* MeshMgr::ms_pMeshMgr = 0;

void MeshMgr::Destroy()
{
	SAFE_DELETE( ms_pMeshMgr );
}

MeshMgr::MeshMgr()
{

}

MeshMgr::~MeshMgr()
{
	Shutdown();
}

bool MeshMgr::Initialize()
{
	return true;
}

void MeshMgr::Shutdown()
{

}

Mesh* MeshMgr::LoadMesh( const std::string& strMeshName, MeshImportType eType )
{
	uint32 uiHash = StrCRC::CRC( strMeshName );

	if ( m_mapMeshes.find( uiHash ) != m_mapMeshes.end() )
		return m_mapMeshes[ uiHash ];

	MeshImporter* pImporter = PipelineMgr::Instance().GetMeshImporter( eType );

	Mesh* pMesh = pImporter->Import( strMeshName );

	m_mapMeshes[ uiHash ] = pMesh;

	return pMesh;
}
